package com.sky.wsp.spring;

import java.io.IOException;
 
public class JarSignerExample {
    public static void main(String[] args) {

        String jarFile = "path/to/your/file.jar"; // 指定JAR文件路径
        String keystore = "d:\\License\\private.p12"; // 指定密钥库路径
        String alias = "idaas"; // 指定密钥别名
        String storepass = "storepass"; // 指定密钥库密码
        String keypass = "storepass"; // 指定密钥密码
 
        ProcessBuilder pb = new ProcessBuilder("jarsigner", "-keystore", keystore, "-storepass", storepass, "-keypass", keypass, "-verify", jarFile, alias);
 
        try {
            Process process = pb.start();
            // 可以从process.getInputStream()获取jarsigner的输出信息
            // 可以从process.getErrorStream()获取错误输出信息
 
            int exitVal = process.waitFor(); // 等待jarsigner执行完成
            System.out.println("Exited with code: " + exitVal);
        } catch (IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}